package com.hf.fetch

class FetchGroup {

	String name
	List<FetchGroup> friendGroups

	static constraints = {
		name(nullable:false, blank:false,unique:true)
	}

	String toString() {
		return "$name"
	}

	static hasMany = [friendGroups : FetchGroup]

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this.is(obj))
			return true;
		if (obj == null)
			return false;
		//		if (getClass() != obj.getClass())
		//			return false;
		FetchGroup other = (FetchGroup) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public boolean isFriend(FetchGroup other) {
		if (friendGroups?.contains(other)) {
			return true
		} else {
			return false
		}
	}

}
